package xin.marcher.module.message.mq.producer;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import xin.marcher.module.common.domain.TraceData;
import xin.marcher.module.common.message.DataChangeMessage;

import java.util.List;

/**
 * 延迟队列消息发送
 */
@Component
public class DataMessageProducer {

    @Autowired
    private DefaultProducer defaultProducer;

    /**
     * 发送消息
     *
     * @param dataChangeMessage
     */
    public void send(DataChangeMessage dataChangeMessage, String topic, Integer delayTimeLevel) {
        defaultProducer.sendMessage(topic, JSONObject.toJSONString(dataChangeMessage), delayTimeLevel, "延迟队列消息发送");
    }

    /**
     * 发送消息
     */
    public void send(List<TraceData> traceDataList, String topic, Integer delayTimeLevel) {
        defaultProducer.sendMessage(topic, JSONObject.toJSONString(traceDataList), delayTimeLevel, "延迟队列消息发送");
    }
}
